
#ifndef _LT2911_H
#define _LT2911_H

//ok
#define _lvds_to_mipi_
//#define _mipi_to_mipi_ //ok
//#define _ttl_to_mipi_  //partly ok

//#define _lvds_to_lvds_
//#define _mipi_to_lvds_
//#define _ttl_to_lvds_

//#define _lvds_to_ttl_ //not support
//#define _mipi_to_ttl_ //not support
//#define _ttl_to_ttl_ //not support

/////////////////////////////////////////////////////////
//#define DISABLE 0
//#define ENABLE 1

//chip select
#define LT2911R 0
#define LT2911R_D 1

//lvds input
#define LVDS_IN_1PORT 1
#define LVDS_IN_2PORT 2

#define VESA 0
#define JEIDA 1

#define SYNC_MODE 0
#define DE_ONLY_MODE 1

#define INPUT_PIN_MAP_0 0
#define INPUT_PIN_MAP_1 1

#define PHASE_N_3 0x70
#define PHASE_N_2 0x30
#define PHASE_N_1 0x10
#define PHASE_0_0 0x11
#define PHASE_P_1 0x01
#define PHASE_P_2 0x03
#define PHASE_P_3 0x07

//MIPI input
#define MIPI_IN_1LANE 1
#define MIPI_IN_2LANE 2
#define MIPI_IN_3LANE 3
#define MIPI_IN_4LANE 0

//TTL input
#define SYNC_MODE_BT656 1
#define SYNC_MODE_BT1120 2
#define SYNC_MODE_IO 3

//mipi output
#define MIPI_OUT_1LANE 1
#define MIPI_OUT_2LANE 2
#define MIPI_OUT_3LANE 3
#define MIPI_OUT_4LANE 0

#define MIPI_CLK_CONTINUOUS 0x03
#define MIPI_CLK_UNCONTINUOUS 0x01

#define MIPI_HBLANK_HS 0x09
#define MIPI_HBLANK_LP 0x0f

#define OUTPUT_PIN_MAP_0 0
#define OUTPUT_PIN_MAP_1 1

//LVDS output
#define LVDS_OUT_1PORT 0x01
#define LVDS_OUT_2PORT 0x02

#define SSC_ON 0x40
#define SSC_OFF 0x00

#define LVDS_OUT_DE_ONLY 0x00
#define LVDS_OUT_SYNC_MOD 0x01

//commmon
#define RGB 0
#define YUV422 1
#define YUV444 2

//rotation
#define ROTATION_LEFT 0
#define ROTATION_RIGHT 1

//retimer
#define RETIMER_MODE_0 0 //input htotal = output vtotal, input vtotal = output htotal,
#define RETIMER_MODE_1 1 //input htotal * vtotal = output htotal * vtotal

//irq
#define RXPLL_CLK_UNSTB 1
#define VID_CHK_CHG 2
#define DDR_FIFO_ERROR 3

#define u8 unsigned char
#define u16 unsigned short
#define u32 unsigned int

typedef struct video_timing {
	u16 hfp;
	u16 hs;
	u16 hbp;
	u16 hact;
	u16 htotal;
	u16 vfp;
	u16 vs;
	u16 vbp;
	u16 vact;
	u16 vtotal;
	u32 pclk_khz;
} video_timing;

void Timer0_Delay1ms(unsigned int nms);

extern void LCD_Reset(void);
void LT2911_show_timing(struct video_timing *t);
/********************************************/
#define bool unsigned char

#endif
